﻿Public Class Frm4BodegasEditar
    Overloads Sub Show(ByVal p_ID As Integer, ByVal p_des As String, ByVal Frm4BodegasMenu As Frm4BodegasMenu)

        Me.lblID.Text = p_ID
        Me.txtNombre.Text = p_des


        Me.Show()
    End Sub
    Public Function cargarBodegas() As Boolean
        'Objeto Roles
        Dim accion As New BodegaDAO
        Dim dato As String = lblID.Text
        'Tabla temporal de roles
        Dim tabla As DataTable
        tabla = accion.mostrarTipoBodegas
        'Comprobar si hay roles
        If tabla Is Nothing Then
            Return False
        Else

            'Trabajar con el control combox
            With cbxTipo
                'No se permite modificar
                .DataSource = accion.mostrarTipoBodegas
                'Fuentes de dtao
                .DropDownStyle = ComboBoxStyle.DropDownList
                'Clave de visualizacion
                .DisplayMember = "Nombre_Bodega"
                'Clave principal
                .ValueMember = "ID_Tipo_Bodega"
                'No mostrar ningun rol
                .SelectedIndex = -1
            End With
            Return True
        End If
    End Function
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Frm4BodegasMenu.Show()
        Me.Close()

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim dato As New Bodega
        Dim accion As New BodegaDAO

        dato.pIdBodega = lblID.Text
        dato.pDescrip = txtNombre.Text
        dato.pIdTBodega = cbxTipo.SelectedValue

        If accion.actualizar(dato) Then
            MessageBox.Show("Registro actualizado", "Modificar", MessageBoxButtons.OK, MessageBoxIcon.Information)

        Else
            MessageBox.Show("No se puede modificar el registro, contacte al administrador", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Warning)
        End If
        Frm4BodegasMenu.Show()
        Me.Close()
    End Sub

    Private Sub Frm4BodegasEditar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cargarBodegas()
    End Sub
End Class